(function(){const configurationData={"version":"v2.86.0","featureFlags":["ewx_498_observer_refactor"],"status":200,"errorDetail":"","instanceId":"exp","makeAsyncCall":false,"cookie":"3cd52509-0dad-44e2-b62a-700e4e8a6a27","cookieOptions":{"domain":"","path":""},"data":[],"asyncCallVars":[],"vars":{"data":[]}};!function(){"use strict";const e="exponea-experiments-editor",t={version:"",status:500,errorDetail:void 0,instanceId:"EWX",sdk:{},sdkObjectName:"",path:"",sign:"",rootElement:document.documentElement,makeAsyncCall:!1,cookie:"",cookieOptions:{},data:[],vars:{data:[]},asyncCallVars:[],featureFlags:[]},n={version:/** {REPLACE_BY: .Version }**/"",status:/** {REPLACE_BY: .Status }**/500,errorDetail:/** {REPLACE_BY: .ErrorDetail }**/void 0,instanceId:/** {REPLACE_BY: .InstanceID }**/"EWX",makeAsyncCall:/** {REPLACE_BY: .MakeAsyncCall }**/!1,cookie:/** {REPLACE_BY: .Cookie }**/"",cookieOptions:/** {REPLACE_BY: .CookieOptionsData }**/{},data:/** {REPLACE_BY: .ModificationsData }**/[],vars:/** {REPLACE_BY: .DataLayerData }**/{data:[]},asyncCallVars:/** {REPLACE_BY: .PageVars }**/[],featureFlags:/** {REPLACE_BY: .FeatureFlags }**/[]};class r{static get window(){return window}static get document(){return document}}function i(e,t,n=void 0){const r=(i=/[\[\]\.]/,t.split(i).filter(Boolean).reduce(((e,t)=>null!=e?e[t]:e),e));var i;return void 0===r?n:r}function s(e){return!Object.entries(e||{}).length&&!(null==e?void 0:e.length)&&!(null==e?void 0:e.size)}function o(e){return"function"==typeof e}function a(e,t){for(const n in e)e.hasOwnProperty(n)&&t(e[n],n,e);return e}const c="_webxp_";function u(e,t){r.window.location.search.match(/[?&]exponea_debug(&|=|$)/)&&(console.log(function(e){return"WebXP ["+(new Date).toUTCString()+"] "+e}(e)),void 0!==t&&console.log(t))}const l=()=>{};function d(e){return null!==(t=e)&&"object"==typeof t&&o(e.remove);var t}function p(e,t){try{return e.matches(t)}catch(e){return!1}}function h(e){const t=e.element;try{const n=document.querySelectorAll(t);return 0===n.length&&("remove"===e.type&&u("The selector matched no elements, ignoring the remove modification",t),"run"!==e.type&&"banner"!==e.type||u("The selector matched no elements but still applying "+e.type+" modification",t)),n}catch(n){return"run"===e.type||"banner"===e.type?u("Invalid selector but still applying the "+e.type+" modification",t):u("Invalid selector of the "+e.type+" modification",t),[]}}function f(e){const t=document.createElement("div");t.innerHTML=e;const n=document.createDocumentFragment();for(;t.firstChild;)n.appendChild(t.firstChild);return n}function m(e){const t=[];for(let n=0;n{var n;return null===(n=t.applied)||void 0===n?void 0:n.has(e)}))||function(e){const t=[],n=e.parentNode;if(!n)return t;const r=n.childNodes;for(let n=0;n{var n;return null===(n=t.applied)||void 0===n?void 0:n.has(e)}))}function v(e,t){const n="before"===t||"after"===t?e.parentElement:e;let r=null;if(n)switch(t){case"before":r=e;break;case"after":r=e.nextSibling;break;case"prepend_child":r=e.firstChild;break;default:r=null}return{parentElement:n,nodeBefore:r}}function y(e,t){"length"in e||(e=[e]),[].forEach.call(e,(function(e){1===e.nodeType&&t(e)}))}function b(e){return c+e}const x=c+"list";function w(e,t){y(e,(e=>{e[x]||(e[x]=[]),-1===e[x].indexOf(t)&&e[x].push(t)}))}function _(e,t){y(e,(e=>{if(!e[x])return;const n=e[x].indexOf(t);-1!==n&&e[x].splice(n,1)}))}function E(e,t){return e[x]&&-1!==e[x].indexOf(t)}function S(e){"loading"!==document.readyState?e({}):document.addEventListener("DOMContentLoaded",e)}function O(){return!!document.getElementById(e)}function k(e,t,n,r){const i={};if(i.inPreview=O(),i.sdk=n,i.data=i.params=t,r)i.element=r,i.elements=[r];else{const t=h(e);t&&t.length>0?(i.element=t[0],i.elements=[].slice.call(t)):(i.element=null,i.elements=[])}i.selector=e.element;const s="parametrized_parts"in e?e.parametrized_parts.script:e.script,o=new Function(s).bind(i);return o.context=i,o}const I=e=>e/1e3;function R(e,t,n,r){var i,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o}function T(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function C(e,t,n,r){return new(n||(n=Promise))((function(t,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function o(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){e.done?t(e.value):new n((function(t){t(e.value)})).then(s,o)}a((r=r.apply(e,[])).next())}))}class L{constructor(){this.subscribers=new Map,this.numberOfEvents=0}subscribe(e,t){var n;const r=null!==(n=this.subscribers.get(e))&&void 0!==n?n:new Map,i=++this.numberOfEvents;return r.set(i,t),this.subscribers.set(e,r),{unsubscribe:()=>r.delete(i)}}publish(e,t){var n;const r=null!==(n=this.subscribers.get(e))&&void 0!==n?n:new Map;for(const[,e]of r)e(t)}}function P(e,t){var n;const r="add_modification",i=t.parametrized_parts?t.parametrized_parts.html:t.html;if(t.applied||(t.applied=new Map),t.applied.has(e)||E(e,r)&&g(e,t))return l;const s=f(i),{parentElement:o,nodeBefore:a}=v(e,t.place_to.placement);if(!o)return l;const c=m(s);return w(s.childNodes,r),null===(n=null==t?void 0:t.applied)||void 0===n||n.set(e,!0),o.insertBefore(s,a),()=>{var n;c.forEach((e=>N(e))),null===(n=t.applied)||void 0===n||n.set(e,!1)}}function N(e){e.parentNode?e.parentNode.removeChild(e):u("Cannot remove an inserted element because its original parent is missing.")}function $(e){let t=l;return e.parentElement&&(t=A.bind(window,e,e.parentElement,e.nextElementSibling),e.parentElement.removeChild(e)),t}function j(e,t){if("visibility"===t.method){const t=e.style.visibility;return e.style.visibility="hidden",()=>{e.style.visibility=t}}if("display"===t.method){const t=e.style.display;return e.style.display="none",()=>{e.style.display=t}}return()=>{}}function A(e,t,n){t?t.insertBefore(e,n):u("Cannot re-insert a removed element because its original parent is missing.")}function D(e,t){if(t.html&&!E(e,t)){const n=f(t.parametrized_parts?t.parametrized_parts.html:t.html),{parentElement:r}=v(e,"before");if(r){const i=m(n);return w(n.childNodes,t),r.insertBefore(n,e),r.removeChild(e),M.bind(window,e,r,i)}}return l}function M(e,t,n){t?(A(e,t,n[0]),n.forEach(N)):u("Cannot re-insert a removed element because its original parent is missing.")}function B(e,t){const n=e.innerHTML;return t.text&&!E(e,t)?(e.innerText=t.text,w(e,t),q.bind(window,e,n,t)):l}function q(e,t,n){_(e,n),e.innerHTML=t}function F(e){const t=[],n=h(e);if(n.length>0&&e.place_to){const r=function(e){let t;try{t=document.querySelector(e)}catch(t){return u("Invalid selector, ignoring the add modification",e),!1}return t||(u("No element matched the selector, ignoring the modification",e),null)}(e.place_to.element);if(r){const{parentElement:i,nodeBefore:s}=v(r,e.place_to.placement);i&&[].forEach.call(n,(function(n){E(n,e)||(t.push(V.bind(window,n,n.parentElement,n.nextSibling,e)),i.insertBefore(n,s),w(n,e))}))}}return t}function V(e,t,n,r){t?(_(e,r),A(e,t,n)):u("Cannot move back element because its original parent is missing.")}function Q(e,t){const n=[];return t.style?(e.hasAttribute("style")||n.push((()=>{e.removeAttribute("style")})),a(t.style,((t,r)=>{const i=e.style.getPropertyValue(r);e.style.setProperty(r,t,"important"),n.push(i?()=>{e.style.setProperty(r,i)}:()=>{e.style.removeProperty(r)})})),()=>{n.forEach((e=>e()))}):()=>{}}function U(e,t){if(!t.attributes)return()=>{};const n={};return a(t.attributes,((t,r)=>{var i;n[r]=e.getAttribute(r),function(e,t){return b(t)in e&&!0===e[b(t)]}(e,"alreadySetAttribute_"+r)||("src"!==r&&"srcset"!==r||e.setAttribute(r,""),e.setAttribute(r,t),i="alreadySetAttribute_"+r,y(e,(e=>{e[b(i)]=!0})))})),H.bind(window,e,n,t)}function H(e,t,n){n.attributes&&a(n.attributes,((r,i)=>{if(n.attributes&&e.getAttribute(i)===n.attributes[i]){const n=t[i];null==n?e.removeAttribute(i):e.setAttribute(i,n)}else u("Attribute `"+i+"` was not reverted because it changed value in meantime.");var s;s="alreadySetAttribute_"+i,y(e,(e=>{delete e[b(s)]}))}))}function K(e,t,n,r){try{if(r&&E(r,e))return()=>{};const i=k(e,t,n,r)();return r&&w(r,e),()=>{r&&_(r,e),o(i)?i():d(i)&&i.remove.call(i)}}catch(e){return u("The run modification script threw an error",e),()=>{}}}function z(e,t,n){try{const r=k(e,t,n);e.parametrized_parts?(r.context.html=e.parametrized_parts.html,r.context.style=e.parametrized_parts.style):(r.context.html=e.html,r.context.style=e.style);const i=r();return d(i)?i.remove.bind(i):()=>{}}catch(e){return u("The banner modification script threw an error",e),()=>{}}}function W(e){let t=[],n=`/* Experiment: ${e.params.experiment_name} (id: ${e.params.experiment_id}) */`,r=`/* Variant: ${e.params.variant_name} (id: ${e.params.variant_id}) */`;if(e.modifications.forEach((function(e){const i=[];if("change"===e.type&&e.style)for(const t in e.style)e.style.hasOwnProperty(t)&&i.push("\t"+t+": "+e.style[t]+" !important;");else"remove"!==e.type||"display"!==e.method&&"visibility"!==e.method||i.push("\t"+e.method+": "+("display"===e.method?"none":"hidden")+" !important;");i.length>0&&("change"===e.type||"remove"===e.type)&&(n&&(t.push(n),n=""),r&&(t.push(r),r=""),t=[...t,e.element+" {",...i,"}"])})),t.length>0){const e=document.createElement("style");return e.type="text/css",e.innerHTML=t.join("\n"),document.getElementsByTagName("head")[0].appendChild(e),N.bind(window,e)}return l}var J;!function(e){e.isDataLayerVariable=function(e){return"data_layer"===e.variable.type},e.isQueryParameterVariable=function(e){return"query"===e.variable.type},e.isJavaScriptVariable=function(e){return"global_variable"===e.variable.type},e.isCustomFunction=function(e){return"custom_function"===e.variable.type}}(J||(J={}));const X="dataLayer";var G;function Y(e,t){return e.data.find((e=>e.id===t))}function Z(e,t){const n=function(e){const t={};return new URL(e).searchParams.forEach(((e,n)=>{t[n]=decodeURIComponent(e)})),t}(t);if(0===Object.keys(n).length)return;const r=e.variable.query.key;if(!r)return;return n[r]}function ee(e,t){let n;if(e)return J.isDataLayerVariable(e)?n=function(e,t){const n=t[X];if(!n)return;const r=e.variable.data_layer.name;if(r)for(let e=n.length-1;e>=0;e--){const t=i(n[e],r,void 0);if(t)return t}}(e,t):J.isQueryParameterVariable(e)?n=Z(e,t.location.href):J.isJavaScriptVariable(e)?n=function(e,t){const n=e.variable.global_variable.name;if(!n)return;const r=i(t,n,void 0);return r||void 0}(e,t):J.isCustomFunction(e)&&(n=function(e){const t=e.variable.custom_function.body;if(!t)return;let n,r;try{n=new Function(t)}catch(e){return}try{r=n()}catch(e){return}return r}(e)),n}function te(e,t=window,n){if(!n)return;if(!(null==e?void 0:e.length))return;const r={};return e.forEach((e=>{const i=e.id,s=Y(n,i);if(!s)return;const o=ee(s,t);void 0!==o&&(r[i]=o)})),s(r)?void 0:r}!function(e){e.matches=function(e,t,n,r){return!r||r.every((r=>{let i;if(!n)return!1;try{const s=r.attribute.id,o=Y(n,s);if(!o)return!1;i=ee(o,e);const a={};return void 0!==i&&(a[s]=i),t(a,s,r.constraint)}catch(e){return!1}}))}}(G||(G={}));class ne{constructor(){this.revertObjects=[]}add({fn:e,experimentId:t,trigger:n}){"function"==typeof e?this.revertObjects.push({fn:e,experimentId:t,trigger:n}):this.revertObjects=[...this.revertObjects,...e.map((e=>({fn:e,experimentId:t,trigger:n})))]}revert(){for(let e=this.revertObjects.length-1;e>=0;e--)try{this.revertObjects[e].fn()}catch(e){u("Error from revert experiment script",e)}this.revertObjects=[]}revertExperiment(e){this.revertRelevant((t=>t.experimentId===e))}revertAllByTrigger(e){this.revertRelevant((t=>t.trigger===e))}revertRelevant(e){var t;this.revertObjects.filter(e).map((e=>e.fn)).forEach((e=>{try{e()}catch(e){u("Error from revert experiment script",e)}})),this.revertObjects=this.revertObjects.filter((t=e,e=>!t(e)))}}function re(e,t,n){return C(this,0,void 0,(function*(){let r,i;u(`${(null==n?void 0:n.method)||"GET"} ${t} (payload: ${null==n?void 0:n.body})`);try{r=yield e.fetch(t,n)}catch(e){throw u(`Error ${(null==n?void 0:n.method)||"GET"} to ${t}.`,e),e}if(!(null==r?void 0:r.ok))throw u(`Error: Received ${null==r?void 0:r.status} from ${t}`),new Error(`Received ${null==r?void 0:r.status} from ${t}`);try{i=yield r.json()}catch(e){throw u(`Error: Unable to create JSON from ${t}`),e}return i}))}const ie=console,se={log:ie.log,warn:ie.warn,debug:ie.debug,error:ie.error};class oe{static isSupported(){if(void 0!==this.cachedIsSupported)return this.cachedIsSupported;try{const e="__storage_test_sample__";return this.getStorage().setItem(e,e),this.getStorage().removeItem(e),this.cachedIsSupported=!0,!0}catch(e){return this.cachedIsSupported=!1,!1}}static getItem(e){return this.isSupported()?this.getStorage().getItem(e):null}static setItem(e,t){this.isSupported()&&this.getStorage().setItem(e,t)}static removeItem(e){this.isSupported()&&this.getStorage().removeItem(e)}static getStorage(){return window.localStorage}}oe.cachedIsSupported=void 0;class ae{static getLastShow(e,t){const n=oe.getItem(this.getLastShowKey(e,t));return n?parseInt(n,10):null}static setLastShow(e,t){const n=""+Date.now();oe.setItem(this.getLastShowKey(e,t),n)}static getLastSessionStart(e){const t=oe.getItem(this.getLastSessionStartKey(e));return t?parseInt(t,10):null}static getLastShowKey(e,t){return this.getEventKeyPrefix(t)+e+"_last_show"}static getEventKeyPrefix(e){return this.getPrefix(e)+"_experiment_event__"}static getLastSessionStartKey(e){return this.getPrefix(e)+"_last_session_start_timestamp__"}static getPrefix(e){let t=e.replace(/^_/,"");return"infinario"===t&&(t="inf"),"__"+t}}var ce,ue,le,de;function pe(e){return function(n,r,i){try{const s=i.type,o=i.operator,a=i.operands;if(ce.whitelist.indexOf(o)>-1)return function(e,t,n,r){const i=e[n];switch(r){case ce.isSet:return null!=i;case ce.isNotSet:return null==i;case ce.hasValue:return he(t)?(null==i?void 0:i.length)>0:i+""!="";case ce.hasNoValue:return he(t)?0===(null==i?void 0:i.length):i+""==""}return!1}(n,s,r,o);if(function(e){return"string"===e}(s))return function(e,n,r,i){if(-1===ue.whitelist.indexOf(r))return t(r,"string"),!1;const s=e[n]+"";let o;switch(r){case ue.equals:return s===i[0].value;case ue.doesNotEqual:return s!==i[0].value;case ue.isIn:return o=i.map((e=>e.value)),o.indexOf(s)>-1;case ue.isNotIn:return o=i.map((e=>e.value)),-1===o.indexOf(s);case ue.contains:return s.indexOf(i[0].value)>-1;case ue.doesNotContain:return-1===s.indexOf(i[0].value);case ue.startsWith:return s.startsWith(i[0].value);case ue.endsWith:return s.endsWith(i[0].value);case ue.matchesRegex:return null!==new RegExp(i[0].value).exec(s)}return!1}(n,r,o,a);if(function(e){return"number"===e}(s))return function(e,n,r,i){if(-1===le.whitelist.indexOf(r))return t(r,"number"),!1;const s=parseFloat(e[n]+""),o=parseFloat(i[0].value);switch(r){case le.equalTo:return s===o;case le.inBetween:return o<=s&&s<=parseFloat(i[1].value);case le.lessThan:return so}return!1}(n,r,o,a);if(function(e){return"boolean"===e}(s))return function(e,n,r,i){if(-1===de.whitelist.indexOf(r))return t(r,"boolean"),!1;const s=e[n]+"",o=i.value+"";if(r===de.is)return s===o;return!1}(n,r,o,i);(function(e){return"date"===e})(s)&&e.error("Value filter: Date type is not supported."),he(s)&&e.error("Value filter: List type is not supported.")}catch(t){e.debug("Value filter error:",t)}return e.debug("Invalid value filter:",i.operator),!1};function t(t,n){e.error("Contextual Bandits: operation "+t+" not suported for type "+n+".")}}function he(e){return"list"===e}function fe(e){return function(t){var n;return me(t.params.experiment_id,t.frequency,e.sdkObjectName)&&function(e,t,n){if(!t||O())return!0;const r=e.experiment_id;try{const i=function(e,t,n){const r={};r.inPreview=O(),r.sdk=t,r.data=r.params=e;let i=n;i.length>0&&i.indexOf("\n")<0&&i.indexOf(";")<0&&i.indexOf("return")<0&&(i="return "+i);const s=new Function(i).bind(r);return s.context=r,s}(e,n,t);return i()||u(`Experiment ${r} was filtered out because of custom condition ${t}.`),!!i()}catch(e){return u(`Custom condition for experiment ${r} threw an error`,e),!1}}(t.params,t.custom_condition,e.sdk)&&ge(null===(n=t.variables_target)||void 0===n?void 0:n.conditions,e.vars)}}function me(e,t,n){if(O())return!0;const r=ae.getLastShow(e,n),i=ae.getLastSessionStart(n);if(!oe.isSupported()&&("only_once"===t||"once_per_visit"===t))return u(`Can't apply experiment ${e} due to missing browser local storage support.`),!1;switch(t){case"only_once":return r&&u(`Experiment ${e} was filtered out because of its frequency only_once.`),!r;case"once_per_visit":return r&&i&&r>=i&&u(`Experiment ${e} was filtered out because of its frequency once_per_visit.`),!r||!i||re)&&!(t.to_date&&t.to_date1&&-1!==t.indexOf("Macintosh")&&-1!==t.indexOf("Safari")&&(n=!0),n}class Se{static matches(e,t){if(!e)return!0;const n=be({ua:t,tablet:!0,featureDetect:!0});return"mobile"===e.type?n:"desktop"!==e.type||!n}}class Oe{static matches(e,t){if("page"in t)return this.matchesURLFilter(e,t.page);if(t.exclude_pages)for(const n of t.exclude_pages)if(this.matchesURLFilter(e,n))return!1;if(t.include_pages)for(const n of t.include_pages)if(this.matchesURLFilter(e,n))return!0;return!1}static parseURL(e){const t={source:e};let n;const r=/^(.{1,5}?):\/\//;(n=r.exec(e))&&(t.protocol=n[1],e=e.replace(r,"")),e.startsWith("//")&&(e=e.substr(2));const i=/(.*?)(\/|$)/;if(n=i.exec(e)){const r=n[1].split(":");""!==r[0]&&(t.host=r[0]),r.length>1&&(t.port=r[1]),e=e.replace(i,"/")}const s=/(.*?)(\?|$|#)/;(n=s.exec(e))&&(t.path=n[1],e=e.replace(s,n[2]));const o=/^\?(.*?)($|#)/;(n=o.exec(e))&&(t.query=n[1],e=e.replace(o,n[2]));if((n=/^#(.*)/.exec(e))&&(t.hash=n[1]),t.withoutHost=t.path,t.query&&(t.withoutHost+=`?${t.query}`),t.hash&&(t.withoutHost+=`#${t.hash}`),t.host){const e=t.port?`:${t.port}`:"";t.withoutProtocol=`//${t.host}${e}${t.withoutHost}`}return t}static escapeRegex(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}static wildcardToRegex(e){const t=("^"+this.escapeRegex(e)+"$").replace(new RegExp("\\\\\\*","g"),".*");return new RegExp(t)}static matchesExactURL(e,t){const n=this.parseURL(e),r=this.parseURL(t);return!(r.host||!r.withoutHost||!n.withoutHost||!n.withoutHost.match(this.wildcardToRegex(r.withoutHost)))||(!(r.protocol||!r.withoutProtocol||!n.withoutProtocol||!n.withoutProtocol.match(this.wildcardToRegex(r.withoutProtocol)))||!!n.source.match(this.wildcardToRegex(r.source)))}static matchesContainsURL(e,t){return e.includes(t)}static matchesRegexURL(e,t){try{const n=new RegExp(t);if(e.match(n))return!0;const r=this.parseURL(e);return!(!r.withoutProtocol||!r.withoutProtocol.match(n))||!(!r.withoutHost||!r.withoutHost.match(n))}catch(e){if(e instanceof Error)return!1;throw e}}static matchesURLFilter(e,t){return"any"===t.type||("exact"===t.type?this.matchesExactURL(e,t.url):"contains"===t.type?this.matchesContainsURL(e,t.url):"regex"===t.type&&this.matchesRegexURL(e,t.regex))}}function ke(e,t,n,r){try{return(e=>Oe.matches(n.href,e.trigger))(e)&&(e=>ve.matches(I((new Date).valueOf()),e.date_filter))(e)&&(e=>Se.matches(e.device_target,r))(e)&&(e=>me(e._id,e.frequency,t.sdkObjectName))(e)&&(e=>{var n;return ge(null===(n=e.variables_target)||void 0===n?void 0:n.conditions,t.vars)})(e)}catch(e){return!1}}function Ie(e){return"run"===e.type&&("repeatedly"===e.execute||"repeatedly_once_per_element"===e.execute)}function Re(e,t,n,r,i){let s=[];const o=[];return setInterval((()=>{s=s.filter((e=>!e.toBeInvalidated))}),15e3),function(a,c,l){var d,p,h;return C(this,0,void 0,(function*(){const f=null===(h=null===(p=null===(d=a.sdk)||void 0===d?void 0:d.configuration)||void 0===p?void 0:p.customer)||void 0===h?void 0:h.cookie;f&&(a.cookie=f,a.sign=a.sign.split("/")[0]+"/"+a.cookie);const m=yield n,g=e=>t=>t.id===e;return m.forEach((n=>{if(!function(e,t,n){var r,i,s;const o=null===(r=null==e?void 0:e.trigger_event)||void 0===r?void 0:r.type;if(o!==t)return!1;if("datalayer_event"===o){const t=null==n?void 0:n.event;return(null===(s=null===(i=null==e?void 0:e.trigger_event)||void 0===i?void 0:i[o])||void 0===s?void 0:s.event)===t}return!1}(n,c,l))return;if(!ke(n,a,e,t))return i(n._id),void(s.find(g(n._id))&&(s=function(e,t){const[n,r]=(i=e,s=e=>e.id===t,i.reduce(((e,t)=>(e[s(t)?0:1].push(t),e)),[[],[]]));var i,s;return n.forEach((e=>e.cancel())),r}(s,n._id)));const d=o.includes(n._id);if(s.find(g(n._id))&&!d)return;const p=function(e,t,n,r){u(`Loading experiment ${e}`);const[i,s]=n.sign.split("/"),o=`${n.path}/campaigns/experiments/show`,a=new AbortController,c=a.signal,l=(()=>C(this,0,void 0,(function*(){var a;let u={};if(null==t?void 0:t.length){const e=r(t,window,n.vars);e&&(u={page_vars:e})}const l=yield re(window,o,{method:"POST",body:JSON.stringify(Object.assign({company_id:i,customer_ids:{cookie:s},personalisation_ids:[e]},u)),signal:c});if(0===(null===(a=null==l?void 0:l.data)||void 0===a?void 0:a.length)&&(null==l?void 0:l.success))return l.data[0];if(!(null==l?void 0:l.data)||1!==l.data.length)throw new Error(`Received unexpected response data from ${o}`);return l.data[0]})))();return{id:e,cancel:()=>a.abort(),promise:l,toBeInvalidated:!1}}(n._id,n.page_vars,a,te);s.push(p),p.promise.then((e=>{e?(p.toBeInvalidated=!1,r(e,d),e.modifications.some(Ie)&&!o.includes(e.params.experiment_id)&&o.push(e.params.experiment_id)):p.toBeInvalidated=!0})).catch(u)})),s}))}}function Te(e,t){const n={};function r(e){return e.params.experiment_id+"_"+e.params.variant_id}e.forEach((e=>{n[r(e)]=e})),t.forEach((t=>{const i=r(t);n[i]?n[i].modifications=[...n[i].modifications,...t.modifications]:e.push(t)}))}class Ce{start(){}stop(){}}class Le{constructor(e,t){this.isObserving=!1,this.config={childList:!0,subtree:!0,attributes:!0,characterData:!1},this.target=e,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.observerCallback=t}start(){this.isObserving||(this.observer.observe(this.target,this.config),this.isObserving=!0)}stop(){this.isObserving&&(this.observer.disconnect(),this.isObserving=!1)}observerHandler(){this.observerCallback();const e=this.observer.takeRecords();this.stop(),e.length&&this.observerCallback(),this.start()}}function Pe(e){return("0"+e.toString(16)).slice(-2)}function Ne(e,t=window){if(e%2)throw new Error("The length of the random string should be an even number!");const n=t.crypto||t.msCrypto;if(n&&n.getRandomValues&&Array.from){const t=new Uint8Array(e/2);return n.getRandomValues(t),Array.from(t,Pe).join("")}let r="";for(let t=0;tt(e)))}function Ae(e,t,n="dataLayer"){t[n]=t[n]||[];!function(e,t,n=!0,r){if(!Array.isArray(e))return;const i=e.push;if(e.push=(...n)=>{const r=i.apply(e,n);try{je(n,t)}catch(e){}return r},n)try{e.forEach((e=>je([e],t)))}catch(e){}}(t[n],e)}var De,Me;!function(e){e.triggerTypes=["page_load","datalayer_event","manual"]}(De||(De={}));class Be{constructor(e){this.config=e,this.pubSub=new L,this.experiments=[],this.alreadyTrackedExperimentsById={},this.revertQueue=new ne,this.config.legacyFlickeringMode?this.observer=new Ce:this.observer=new Le(e.rootElement,(()=>{this.applyExperimentsOnAllElements()})),this.metaDataPromise=function(e){return C(this,0,void 0,(function*(){const t=e.sign.split("/")[0],n=e.path+"/webxp/projects/"+t+"/bundle";let r;try{r=yield re(window,n)}catch(e){}let i=[];return(null==r?void 0:r.experiments)&&(i=r.experiments),i}))}(this.config);const t=Re(location,window.navigator.userAgent,this.metaDataPromise,((e,t)=>this.startExperiment(e,t)),(e=>this.stopExperiment(e)));this.pubSub.subscribe("datalayer_event",(e=>t(this.config,"datalayer_event",e)));Ae((e=>{e&&"object"==typeof e&&(u(`DataLayer event triggered: ${JSON.stringify(e)}`),this.pubSub.publish("datalayer_event",e))}),window)}init(e=!1,t="page_load"){if(200!==this.config.status&&u("Web modifications ended up with status "+this.config.status),!this.config.skipExperiments)return u("Experiments was not applied by non-flickering script because skipExperiments=false"),void this.revealPage();this.config.cookie&&(this.config.sign=this.config.sign.split("/")[0]+"/"+this.config.cookie),this.config.sdk.initialize(!1),this.applyExperiments(this.config.data,!0),this.loadRemainingDataIfNeeded(e,t),this.revealPage()}applyModifications(e){return this.config.legacyFlickeringMode||this.revert(),this.config.data=[e],this.experiments=[],this.config.status=200,this.applyExperiments(this.config.data,!1),()=>{this.revert()}}reset(e){var t,n;const r=e=>"datalayer_event"===e.trigger_type;this.observer.stop(),this.revertQueue.revertAllByTrigger("page_load"),this.experiments=this.experiments.filter(r),this.config.data=this.config.data.filter(r),this.config.cookie=(null===(n=null===(t=this.getSDK().configuration)||void 0===t?void 0:t.customer)||void 0===n?void 0:n.cookie)||"",e&&De.triggerTypes.includes(e)||(e="manual"),this.init(!0,e)}revert(){this.observer.stop(),this.revertQueue.revert(),this.experiments=[]}applyModificationOnElement(e,t,n,r=!1){const i=n.params.experiment_id;if(r)"run"===t.type&&"repeatedly_once_per_element"===t.execute&&p(e,t.element)&&this.revertQueue.add({fn:K(t,n.params,this.getSDK(),e),experimentId:i,trigger:n.trigger_type});else if("add"===t.type&&p(e,t.place_to.element))this.revertQueue.add({fn:P(e,t),experimentId:i,trigger:n.trigger_type});else if("change"===t.type||"run"===t.type){const r=p(e,t.element);"change"===t.type?((r||t.place_to&&p(e,t.place_to.element))&&(t.html&&this.revertQueue.add({fn:D(e,t),experimentId:i,trigger:n.trigger_type}),t.text&&this.revertQueue.add({fn:B(e,t),experimentId:i,trigger:n.trigger_type}),t.place_to&&this.revertQueue.add({fn:F(t),experimentId:i,trigger:n.trigger_type}),t.attributes&&!s(t.attributes)&&this.revertQueue.add({fn:U(e,t),experimentId:i,trigger:n.trigger_type})),t.style&&r&&this.revertQueue.add({fn:Q(e,t),experimentId:i,trigger:n.trigger_type})):"run"===t.type&&t.execute&&["repeatedly_once_per_element","once_per_element"].includes(t.execute)&&r&&this.revertQueue.add({fn:K(t,n.params,this.getSDK(),e),experimentId:i,trigger:n.trigger_type})}else"remove"===t.type&&"remove"===t.method&&p(e,t.element)?this.revertQueue.add({fn:$(e),experimentId:i,trigger:n.trigger_type}):"remove"===t.type&&("visibility"===t.method||"display"===t.method)&&p(e,t.element)&&this.config.legacyFlickeringMode&&this.revertQueue.add({fn:j(e,t),experimentId:i,trigger:n.trigger_type})}applyExperiments(e,t,n=!1){const r=JSON.parse(JSON.stringify(e)),i=t&&!n?r.filter(fe(this.config)):r;this.observer.stop(),u("Applying experiments ...",i),n||this.trackExperiments(i),this.applyOneTimeModifications(i,n),n||this.applyOnDocumentReadyModifications(i),Te(this.experiments,i),this.observer.start(),this.applyExperimentsOnAllElements(n)}applyOneTimeModifications(e,t){e.forEach((e=>{const n=e.params.experiment_id;t||this.revertQueue.add({fn:W(e),experimentId:n,trigger:e.trigger_type}),e.modifications.forEach((r=>{"run"!==r.type||("immediately"!==r.execute||t)&&"repeatedly"!==r.execute||this.revertQueue.add({fn:K(r,e.params,this.getSDK()),experimentId:n,trigger:e.trigger_type})}))}))}applyOnDocumentReadyModifications(e){S((()=>{e.forEach((e=>{const t=e.params.experiment_id;e.modifications.forEach((n=>{"run"!==n.type||n.execute&&"document_ready"!==n.execute?"banner"===n.type&&this.revertQueue.add({fn:z(n,e.params,this.getSDK()),experimentId:t,trigger:e.trigger_type}):this.revertQueue.add({fn:K(n,e.params,this.getSDK()),experimentId:t,trigger:e.trigger_type})}))}))}))}getSDK(){return O()?function(){let e=!1;return{initialize(){},track(){},trackLink(){},identify(){},update(){},anonymize(){},_revealPage(){},configuration:{},notifications:{isAvailable:e=>(e(!0),!0),isSubscribed:t=>(t(e,!1),e),subscribe(t){setTimeout((()=>{e=!0,t("subscribed")}),500)},unsubscribe(t){setTimeout((()=>{e=!1,t("unsubscribed")}),500)}}}}():window[this.config.sdkObjectName]}trackExperiments(e){e.forEach((e=>{O()||(ae.setLastShow(e.params.experiment_id,this.config.sdkObjectName),this.alreadyTrackedExperimentsById[e.params.experiment_id]||(this.getSDK().track("experiment",{action:"show",experiment_id:e.params.experiment_id,experiment_name:e.params.experiment_name,variant_id:e.params.variant_id,variant_name:e.params.variant_name,location:window.location.href,path:window.location.pathname}),this.alreadyTrackedExperimentsById[e.params.experiment_id]=!0))}))}loadRemainingDataIfNeeded(e=!1,t){return C(this,0,void 0,(function*(){if(e||this.config.makeAsyncCall||200!==this.config.status){const n=200===this.config.status;let r=this.config.path+"/webxp/data/modifications/"+this.config.sign+"/v1",i=!1;r+="?http-referer="+encodeURIComponent(location.href),!e&&n||(r+="&allModifications=true",i=!0),r+=`&trigger=${t}`;let s=this.config.asyncCallVars;const o=e=>!!e.page_vars;if(e||!n){s=(yield this.metaDataPromise).filter(o).flatMap((e=>e.page_vars))}let a,c;if(null==s?void 0:s.length){const e=te(s,window,this.config.vars);if(e){const t={page_vars:e};let n;try{n=JSON.stringify(t)}catch(t){u(`Error serializing ${e} to json.`,t)}t&&(a={method:"POST",headers:{"Content-Type":"application/json"},body:n})}}try{c=yield re(window,r,a)}catch(e){}return this.processResponse(c,i)}}))}startExperiment(e,t){this.isExperimentRunning(e.params.experiment_id)&&!t||(u(`Starting experiment ${e.params.experiment_id}`),this.applyExperiments([e],!0,t))}applyExperimentsOnAllElements(e=!1){for(const t of this.experiments)for(const n of t.modifications){const r=Fe(qe(n));for(const i of r)this.applyModificationOnElement(i,n,t,e)}}isExperimentRunning(e){return this.experiments.some((t=e,e=>e.params.experiment_id===t));var t}stopExperiment(e){this.isExperimentRunning(e)&&(u(`Stopping experiment ${e}`),this.revertQueue.revertExperiment(e),this.experiments=this.experiments.filter((t=>t.params.experiment_id!==e)))}revealPage(){const e=this.getSDK();e._revealPage&&"function"==typeof e._revealPage&&e._revealPage()}processResponse(e,t=!1){e&&e.data&&(u(`Adding new experiments data, ${e.data}, to current data.`),Te(this.config.data,e.data),t&&(this.config.vars=e.vars),u("Applying new experiments data ..."),this.applyExperiments(e.data,!0))}}function qe(e){const t=[],n=e=>{"string"==typeof e&&t.push(e)};return n(e.element),e.place_to&&n(e.place_to.element),t}function Fe(e){return e.flatMap((e=>Array.from(document.querySelectorAll(e)))).filter((e=>e instanceof HTMLElement))}let Ve;R([$e,T("design:type",Function),T("design:paramtypes",[Boolean,String]),T("design:returntype",void 0)],Be.prototype,"init",null),R([$e,T("design:type",Function),T("design:paramtypes",[Object]),T("design:returntype",Function)],Be.prototype,"applyModifications",null),R([$e,T("design:type",Function),T("design:paramtypes",[String]),T("design:returntype",void 0)],Be.prototype,"reset",null),R([$e,T("design:type",Function),T("design:paramtypes",[]),T("design:returntype",void 0)],Be.prototype,"revert",null);try{configurationData,Ve=!0}catch(e){Ve=!1}const Qe="webxpClient",Ue="webxpClientInitialConfig";let He;(null===(Me=window[Qe])||void 0===Me?void 0:Me.reset)||(window[Ue]=window[Qe]),He=Ve?Object.assign(Object.assign(Object.assign({},t),configurationData),window[Ue]):Object.assign(Object.assign(Object.assign({},t),n),window[Ue]);const Ke=new Be(He);if(window[Qe]={init:Ke.init.bind(Ke),revert:Ke.revert.bind(Ke),applyModifications:Ke.applyModifications.bind(Ke),config:Ke.config,skipExperiments:He.skipExperiments,reset:Ke.reset.bind(Ke)},Ke.config.legacyFlickeringMode&&function(){if(!function(){try{const e="___storage_test__";return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return!1}}())return!1;try{return!!window.sessionStorage.getItem("exponea-editor-params")}catch(e){return!1}}()){const e=Ke.config.sdk;e._revealPage&&"function"==typeof e._revealPage&&e._revealPage()}else Ke.init()}(); //# sourceMappingURL=modifications.min.js.map })()